package onion.molingo2o.activity.request;

import android.content.Context;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ListView;

import com.easemob.chatuidemo.ui.BaseActivity;

import onion.molingo2o.R;

/**
 * 搜索activity
 * Created by Administrator on 2015/12/20.
 */
public class SearchActivity extends BaseActivity {
    EditText query;
    ListView lv;

    @Override
    protected void onCreate(Bundle arg0) {
        super.onCreate(arg0);
        setContentView(R.layout.activity_search);
        query = (EditText) findViewById(R.id.query);
        lv = (ListView) findViewById(R.id.lv);
        query.setOnKeyListener(new View.OnKeyListener() {
            @Override
            public boolean onKey(View v, int keyCode, KeyEvent event) {
                if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN) {
                    /*隐藏软键盘*/
                    InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                    if (inputMethodManager.isActive()) {
                        inputMethodManager.hideSoftInputFromWindow(v.getApplicationWindowToken(), 0);
                    }
                    String searchName = query.getText().toString();
                    if (searchName != null && searchName.length() != 0) {
                        return true;
                    }
                }
                return false;
            }
        });
    }
}
